package bairui.international.console.web.controller.barter.property.item;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianjing.sh.spring.web.controller.base.action.Action;
import com.lianjing.sh.spring.web.controller.enhance.output.FomatOutput;
import com.sh_lianjing.util.Util_BeanCopyByDeclaredProperties;

import bairui.international.model.domain.jpa.TB_ProductProperty;
import bairui.international.model.domain.jpa.TB_ProductPropertyItem;
import bairui.international.service.Service_ProductPropertyItem;

/**
 *
 * 属性项添加
 *
 * @generated
 * 
 * @see STest_C_Barter_Property_PropertyItemAdd_Add 测试
 *
 */
@Controller
public class C_Barter_Property_PropertyItemAdd_Add
 extends SC_Barter_Property_PropertyItemAdd_Add 
{
	
	@Autowired private Service_ProductPropertyItem service_ProductPropertyItem;
	
	/**
	 * 添加
	 */
	@Action(Add.class)
	@PostMapping(Add.RequestMappingValue)
	public @FomatOutput @ResponseBody Object add(
		@Valid Add.InputModel input, 
		@PathVariable(name=Add.PathVariableName.PropertyId) long propertyId
	) throws Exception {
		TB_ProductPropertyItem bean = new TB_ProductPropertyItem();
		// 保存数据
		TB_ProductPropertyItem result = Util_BeanCopyByDeclaredProperties.copyProperties(input, bean);
			result.setProductProperty(new TB_ProductProperty(propertyId));
		service_ProductPropertyItem.save(result);
		//
		return null;
	}
	

}
